<?php

// Create control panel class
class ControlPanel {

	// Store default settings
	var $default_settings = Array(
	'style' => 'default',
	'language' => 'english.php',
	'text_direction' => 'ltr',
	'crop' => '1',
	'quality' => '95',
	'FTwidth' => '180',
	'FTheight' => '130',
	'MTwidth' => '100',
	'MTheight' => '75',
	'GTwidth' => '100',
	'GTheight' => '75',
	'logo' => '1',
	'loptions' => '1',
	'loading' => '0',
	'social' => '1',
	'closewidget' => '1',
	'viewed_num' => '10',
	'recent_num' => '10',
	'discussed_num' => '10',
	'featured_n' => '10',
	'videose' => '1',
	'leftcatsN' => '4',
	'rightcatsN' => '4',
	'adblock1' => '<a href="#"><img src="http://a248.e.akamai.net/f/248/580/1d/pics.drugstore.com/prodimg/promo/assoclinks/468x60_olay.gif" alt="" /></a>',
	'adblock2' => '<a href="#"><img src="http://a248.e.akamai.net/f/248/580/1d/pics.drugstore.com/prodimg/promo/assoclinks/300x250_olay.gif" alt="" /></a>',
	'adblock3' => '<a href="#"><img src="http://www.digitalsignageexpo.net/Portals/0/DSE_AdvertiseHere728x90_01.gif" alt="" /></a>',
	'leftpostnum' => '1',
	'rightpostnum' => '1',
	'feed_name' => '',
	'featured' => '',
	'excluded' => '',
	'videos' => ''
	);

	var $options;

	// Add the menus / head to admin panel
	function ControlPanel() {
	global $cpanel;
    add_action('admin_menu', array(&$this, 'add_menu'));
	add_action('admin_head', array(&$this, 'admin_head'));
	if (!is_array(get_option($cpanel['name'])))
	add_option($cpanel['name'], $this->default_settings);
	$this->options = get_option($cpanel['name']);
	}

	// Add Control panel menus
	function add_menu() {
	global $cpanel;
	add_menu_page('DeluxeThemes', 'DeluxeThemes', 10, 'options', array(&$this, 'optionsmenu'), $cpanel['img_dir'].'cp.png');
	add_submenu_page('options', 'General Options', 'General Options', 10, 'options', array(&$this, 'optionsmenu'));
	add_submenu_page('options', 'Thumbnail Options', 'Thumbnail Options', 10, 'thumbnails', array(&$this, 'optionsmenu'));
	add_submenu_page('options', 'QuickVideo Publisher', 'QuickVideo Publisher', 10, 'quickvideo', array(&$this, 'optionsmenu'));
	add_submenu_page('options', 'Ad Management', 'Ad Management', 10, 'admanager', array(&$this, 'optionsmenu'));
	add_submenu_page('options', 'Manage Styles', 'Manage Styles', 10, 'styles', array(&$this, 'optionsmenu'));
	add_submenu_page('options', 'Manage Languages', 'Manage Languages', 10, 'languages', array(&$this, 'optionsmenu'));
	add_submenu_page('options', 'System Info', 'System Info', 10, 'system', array(&$this, 'optionsmenu'));
	}
	
	// Add CSS and JavaScript (Header)
	function admin_head() {
	global $cpanel;
	print '<link rel="stylesheet" href="'.$cpanel['css_dir'].'style.css" type="text/css" media="screen" />';
	}

	// Process options page
	function optionsmenu() {
	global $cpanel;

	function remove_ext($filename) {
		$file = substr($filename, 0,strrpos($filename,'.'));
		return $file;
	}
	
	print '<script type="text/javascript" src="'.$cpanel['js_dir'].'jquery-1.3.1.min.js"></script>';
	print '<script type="text/javascript" src="'.$cpanel['js_dir'].'jquery.textarearesizer.js"></script>';
	print '<script type="text/javascript">
			$(document).ready(function() {
			$("textarea.resizable:not(.processed)").TextAreaResizer();
			});
			</script>';

	// Load an appropriate options page
	include_once $cpanel['modules_dir'].$_GET['page'].'.php';
	
	}

} // End control panel class

// Make $options array
$new_control_panel = new ControlPanel();
$options = get_option($cpanel['name']);

?>